package com.lovo.homework7_14ATM;

import javax.swing.*;
import java.awt.*;
import java.util.Map;

public class ATMmain extends JFrame {
    private DepositPanel depositPanel = new DepositPanel();
    private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel();
    private QueryPanel queryPanel = new QueryPanel();
    private WithdrawPanel withdrawPanel = new WithdrawPanel();

    private CardLayout cardLayout = new CardLayout();

    private Image bgImage = util.Util.getImage("/images/background.jpg");

    public ATMmain() {
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImage, 0, 0, 1024, 768, this);
            }
        });

        this.setLayout(cardLayout);
        this.add("loginPanel",loginPanel);
        this.add("menuPanel",menuPanel);
        this.add("depositPanel",depositPanel);
        this.add("withDraw",withdrawPanel);
        this.add("queryPanel",queryPanel);

        this.setSize(1024, 768);
        this.setTitle("中国银行客户端");
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);
    }
    public void switchPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }

    public static void main(String[] args) {
        new ATMmain();
    }
}
